#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;
double calculateArea(string shape, double a = 1.0, double b = 1.0, double c = 1.0)
{
	if (shape._Equal("circle")) {
		return acos(-1) * pow(a, 2);
	}
	else if (shape._Equal("rectangle")) {
		return a * b;
	}
	else if (shape._Equal("triangle")) {
		double q = (a + b + c) / 2.0; 
		return sqrt(q * (q - a) * (q - b) * (q - c));
	}
}
int main()
{
	int shapeChoice;
	cout << "请输入要计算的图形类型(1-圆形，2-矩形，3-三角形): ";
	cin >> shapeChoice;
	if (shapeChoice == 1) {
		double radius;
		cout << "请输入“圆形”的半径：";
		cin >> radius;
		cout << "该图形为圆形，其面积为：" << calculateArea("circle", radius) << endl;
	}
	else if (shapeChoice == 2) {
		double length, width;
		cout << "请输入“矩形”的长度和宽度：";
		cin >> length >> width;
		cout << "该图形为矩形，其面积为：" << calculateArea("rectangle", length, width) << endl;
	}
	else if (shapeChoice == 3) {
		double a, b, c;
		cout << "请输入“三角形”的边长：";
		cin >> a >> b >> c;
		cout << "该图形为三角形，其面积为：" << calculateArea("triangle", a, b, c) << endl;
	}
	else {
		cout << "非法输入！" << endl;
	}
	system("pause");
	return 0;
}